fix(MAJORLEA-005-2): frontend/src/services/hiring.ts silently swallows errors and returns empty array instead of throwing - #79
Conversation
…s errors and returns empty array instead of throwing
| @@ -2,12 +2,6 @@ import { JobOpening } from '../types/hiring'; | |||
| import { getJobOpenings } from './api'; | |||
|
|
|||
| export const fetchJobOpenings = async (): Promise<JobOpening[]> => { | |||
There was a problem hiding this comment.
🦩 🔴 frontend/src/services/hiring.ts silently swallows errors and returns empty array instead of throwing
Removed the try/catch block in fetchJobOpenings entirely, so any error thrown by getJobOpenings() (network failure, non-success status, etc.) now propagates to the caller (useHiring hook) instead of being silently swallowed and returning an empty array. The caller can now distinguish a real failure from a legitimately empty job list and show proper error UI. The console.error log and the return [] fallback were both removed. If getJobOpenings() itself does not already throw on response.data.status !== 'success', that check would need to be added in api.ts (not in scope here); however, this change is the correct minimal fix for the silent-swallow pattern identified in this file.
🤖 Prompt for AI agents
In frontend/src/services/hiring.ts around line 4, review and complete this code-review fix: frontend/src/services/hiring.ts silently swallows errors and returns empty array instead of throwing.
What the draft fix changed: Removed the try/catch block in `fetchJobOpenings` entirely, so any error thrown by `getJobOpenings()` (network failure, non-success status, etc.) now propagates to the caller (`useHiring` hook) instead of being silently swallowed and returning an empty array. The caller can now distinguish a real failure from a legitimately empty job list and show proper error UI. The `console.error` log and the `return []` fallback were both removed. If `getJobOpenings()` itself does not already throw on `response.data.status !== 'success'`, that check would need to be added in `api.ts` (not in scope here); however, this change is the correct minimal fix for the silent-swallow pattern identified in this file.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer
Closes findings from rule MAJORLEA-005-2 — frontend/src/services/hiring.ts silently swallows errors and returns empty array instead of throwing.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
frontend/src/services/hiring.ts:4What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
8f1c6ef6-6b61-4dcd-bb0e-59bc6a7d37e8Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.